package io.adrainty.bolee.trade.feign.impl;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.adrainty.bolee.trade.feign.IPeriodicPayFeign;
import io.adrainty.bolee.trade.handler.IPayHandler;
import io.adrainty.bolee.trade.handler.PayHandlerRegistry;
import io.adrainty.bolee.trade.models.entity.TradeEntity;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>PeriodicPayFeignImpl</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description PeriodicPayFeignImpl
 * @since 2025/9/12 14:45:08
 */

@RestController
@RequestMapping("trade-periodic-feign")
public class PeriodicPayFeignImpl implements IPeriodicPayFeign {

    @Resource
    private PayHandlerRegistry handlerRegistry;

    @Override
    @PostMapping("/h5-sign-contract")
    public ResultDTO<TradeEntity> h5SignContract(@RequestBody TradeEntity tradeVO) {
        IPayHandler payHandler = handlerRegistry.strictGetPayChannel(tradeVO.getTradeChannel());
        TradeEntity result = payHandler.h5SignContract(tradeVO);
        return ResultDTOUtil.success(result);
    }

}

